<template>
  <div class="left-chart-1">
    <div class="lc1-header">张三收费站</div>
    <div class="lc1-details">设备运行总数<span>430</span></div>
    <dv-capsule-chart class="lc1-chart" :config="config" />
    <dv-decoration-2 style="height: 10px" />
  </div>
</template>

<script>
// 引入js，不需要带后缀
import api from '@/api/selfApi'
export default {
  name: 'LeftChart1',
  data() {
    return {
      param: { vvvv: '前端vscode' },
      config: {
        data: [
          {
            name: '收费系统',
            value: 167
          },
          {
            name: '通信系统',
            value: 67
          },
          {
            name: '监控系统',
            value: 123
          },
          {
            name: '供配电系统',
            value: 55
          },
          {
            name: '其他',
            value: 111
          }
        ],
        colors: ['#00baff', '#3de7c9', '#fff', '#ffc530', '#469f4b'],
        unit: '件',
        showValue: true
      }
    }
  },
  created: function() {
    this.queryView()
  },
  methods: {
    queryView() {
      var _this = this
      api.analyse
        .queryView({ vvvv: '前端vscode' })
        .then(
          (response) => {
            // 处理逻辑
            console.log(response)
            _this.config.data[0].name = response
            this.config = { ...this.config }
          },
          (error) => {
            console.log('接口报错')
          }
        )
        .catch((error) => {
          console.log('处理逻辑出错')
        })
    }
  }
}
</script>

<style lang="scss" scoped>
.left-chart-1 {
  width: 100%;
  height: 37%;
  display: flex;
  flex-grow: 0;
  flex-direction: column;
  .lc1-header {
    text-align: center;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    margin-bottom: 20px;
  }
  .lc1-details {
    height: 50px;
    font-size: 16px;
    display: flex;
    align-items: center;
    text-indent: 20px;
    span {
      color: #096dd9;
      font-weight: bold;
      font-size: 35px;
      margin-left: 20px;
    }
  }
  .lc1-chart {
    flex: 1;
  }
}
</style>
